/*     */ package org.jeecgframework.p3.cg;
/*     */ 
/*     */ import java.io.File;
/*     */ import java.io.FileWriter;
/*     */ import java.io.IOException;
/*     */ import java.io.PrintStream;
/*     */ import java.sql.Connection;
/*     */ import java.sql.DriverManager;
/*     */ import java.sql.PreparedStatement;
/*     */ import java.sql.ResultSet;
/*     */ import java.sql.SQLException;
/*     */ import java.text.SimpleDateFormat;
/*     */ import java.util.ArrayList;
/*     */ import java.util.Date;
/*     */ import java.util.HashMap;
/*     */ import java.util.List;
/*     */ import java.util.Map;
/*     */ import org.apache.commons.lang.StringUtils;
/*     */ import org.jeecgframework.p3.cg.def.CodeResourceUtil;
/*     */ import org.jeecgframework.p3.cg.def.TableConvert;
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ public class CreateBean
/*     */ {
/*  33 */   private Connection connection = null;
/*     */   static String url;
/*     */   static String username;
/*     */   static String password;
/*  37 */   static String rt = "\r\t";
/*  38 */   String SQLTables = "show tables";
/*     */   private String method;
/*     */   
/*  41 */   static { try { Class.forName("com.mysql.jdbc.Driver");
/*     */     } catch (Exception e) {
/*  43 */       e.printStackTrace();
/*     */     }
/*     */   }
/*     */   
/*     */   public void setMysqlInfo(String url, String username, String password) {
/*  48 */     this.url = url;
/*  49 */     this.username = username;
/*  50 */     this.password = password;
/*     */   }
/*     */   
/*  53 */   public void setConnection(Connection connection) { this.connection = connection; }
/*     */   
/*     */ 
/*  56 */   public Connection getConnection() throws SQLException { return DriverManager.getConnection(url, username, password); }
/*     */   
/*     */   public List<String> getTables() throws SQLException {
/*  59 */     Connection con = getConnection();
/*  60 */     PreparedStatement ps = con.prepareStatement(this.SQLTables);
/*  61 */     ResultSet rs = ps.executeQuery();
/*  62 */     List<String> list = new ArrayList();
/*  63 */     while (rs.next()) {
/*  64 */       String tableName = rs.getString(1).toUpperCase();
/*  65 */       list.add(tableName);
/*     */     }
/*  67 */     rs.close();
/*  68 */     ps.close();
/*  69 */     con.close();
/*  70 */     return list;
/*     */   }
/*     */   
/*     */   public List<TableInfo> getTablesInfo() throws SQLException {
/*  74 */     String SQLTables = "select t.TABLE_NAME ,t.TABLE_COMMENT from information_schema.tables  t  WHERE table_schema = '" + CodeResourceUtil.getDATABASE_NAME() + "'";
/*  75 */     Connection con = getConnection();
/*  76 */     PreparedStatement ps = con.prepareStatement(SQLTables);
/*  77 */     ResultSet rs = ps.executeQuery();
/*  78 */     List<TableInfo> list = new ArrayList();
/*  79 */     while (rs.next()) {
/*  80 */       TableInfo tableInfo = new TableInfo();
/*  81 */       String tableName = rs.getString(1);
/*  82 */       String tableComment = rs.getString(2);
/*  83 */       tableInfo.setTableName(tableName);
/*  84 */       tableInfo.setTableComment(tableComment);
/*  85 */       list.add(tableInfo);
/*     */     }
/*  87 */     rs.close();
/*  88 */     ps.close();
/*  89 */     con.close();
/*  90 */     return list;
/*     */   }
/*     */   
/*     */   public Map<String, String> getTableCommentMap() throws SQLException {
/*  94 */     String SQLTables = "select t.TABLE_NAME ,t.TABLE_COMMENT from information_schema.tables  t  WHERE table_schema = '" + CodeResourceUtil.getDATABASE_NAME() + "'";
/*  95 */     Connection con = getConnection();
/*  96 */     PreparedStatement ps = con.prepareStatement(SQLTables);
/*  97 */     ResultSet rs = ps.executeQuery();
/*  98 */     Map<String, String> map = new HashMap();
/*  99 */     while (rs.next()) {
/* 100 */       String tableName = rs.getString(1).toUpperCase();
/* 101 */       String tableComment = rs.getString(2);
/* 102 */       map.put(tableName, tableComment);
/*     */     }
/* 104 */     rs.close();
/* 105 */     ps.close();
/* 106 */     con.close();
/* 107 */     return map;
/*     */   }
/*     */   
/*     */ 
/*     */ 
/*     */ 
/*     */   public List<ColumnData> getColumnDatas(String tableName)
/*     */     throws SQLException
/*     */   {
/* 116 */     String SQLColumns = "select column_name ,data_type,column_comment,0,0,character_maximum_length,is_nullable nullable,COLUMN_KEY from information_schema.columns where table_name =  '" + tableName + "' " + "and table_schema =  '" + CodeResourceUtil.DATABASE_NAME + "'";
/*     */     
/* 118 */     Connection con = getConnection();
/* 119 */     PreparedStatement ps = con.prepareStatement(SQLColumns);
/* 120 */     List<ColumnData> columnList = new ArrayList();
/* 121 */     ResultSet rs = ps.executeQuery();
/* 122 */     StringBuffer str = new StringBuffer();
/* 123 */     StringBuffer getset = new StringBuffer();
/* 124 */     while (rs.next()) {
/* 125 */       String name = rs.getString(1);
/* 126 */       String type = rs.getString(2);
/* 127 */       String comment = rs.getString(3);
/* 128 */       String precision = rs.getString(4);
/* 129 */       String scale = rs.getString(5);
/* 130 */       String charmaxLength = rs.getString(6) == null ? "" : rs.getString(6);
/* 131 */       String nullable = TableConvert.getNullAble(rs.getString(7));
/* 132 */       String columnKey = rs.getString(8) == null ? "" : rs.getString(8);
/* 133 */       String dataType = getType(type, precision, scale);
/* 134 */       String domainPropertyName = getcolumnNameToDomainPropertyName(name);
/* 135 */       String jdbcType = getJdbcType(type, precision, scale);
/*     */       
/* 137 */       ColumnData cd = new ColumnData();
/* 138 */       cd.setColumnName(name);
/* 139 */       cd.setDataType(dataType);
/* 140 */       cd.setJdbcType(jdbcType);
/* 141 */       cd.setColumnType(rs.getString(2));
/* 142 */       cd.setColumnComment(comment);
/* 143 */       cd.setPrecision(precision);
/* 144 */       cd.setScale(scale);
/* 145 */       cd.setCharmaxLength(charmaxLength);
/* 146 */       cd.setNullable(nullable);
/* 147 */       cd.setDomainPropertyName(domainPropertyName);
/* 148 */       cd.setColumnKey(columnKey);
/* 149 */       columnList.add(cd);
/*     */     }
/* 151 */     this.argv = str.toString();
/* 152 */     this.method = getset.toString();
/* 153 */     rs.close();
/* 154 */     ps.close();
/* 155 */     con.close();
/* 156 */     return columnList;
/*     */   }
/*     */   
/*     */ 
/*     */   public List<ColumnData> getColumnKeyDatas(List<ColumnData> columnList)
/*     */   {
/* 162 */     List<ColumnData> columnKeyList = new ArrayList();
/* 163 */     if ((columnList != null) && (columnList.size() > 0)) {
/* 164 */       for (ColumnData column : columnList) {
/* 165 */         if ("PRI".equals(column.getColumnKey())) {
/* 166 */           columnKeyList.add(column);
/*     */         }
/*     */       }
/*     */     }
/* 170 */     return columnKeyList;
/*     */   }
/*     */   
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */   public String getColumnKeyParam(List<ColumnData> columnList)
/*     */   {
/* 182 */     StringBuffer sb = new StringBuffer("");
/* 183 */     if ((columnList != null) && (columnList.size() > 0)) {
/* 184 */       for (ColumnData column : columnList) {
/* 185 */         sb.append(column.getDataType()).append(" ").append(column.getDomainPropertyName()).append(",");
/*     */       }
/*     */     }
/* 188 */     String str = sb.toString();
/* 189 */     if (str.length() > 0) {
/* 190 */       str = str.substring(0, str.length() - 1);
/*     */     }
/* 192 */     return str;
/*     */   }
/*     */   
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */   public String getColumnKeyUseParam(List<ColumnData> columnList)
/*     */   {
/* 204 */     StringBuffer sb = new StringBuffer("");
/* 205 */     if ((columnList != null) && (columnList.size() > 0)) {
/* 206 */       for (ColumnData column : columnList) {
/* 207 */         sb.append(column.getDomainPropertyName()).append(",");
/*     */       }
/*     */     }
/* 210 */     String str = sb.toString();
/* 211 */     if (str.length() > 0) {
/* 212 */       str = str.substring(0, str.length() - 1);
/*     */     }
/* 214 */     return str;
/*     */   }
/*     */   
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */   public String getBeanFeilds(String tableName, String className)
/*     */     throws SQLException
/*     */   {
/* 227 */     List<ColumnData> dataList = getColumnDatas(tableName);
/* 228 */     StringBuffer str = new StringBuffer();
/* 229 */     StringBuffer getset = new StringBuffer();
/* 230 */     for (ColumnData d : dataList) {
/* 231 */       String name = d.getDomainPropertyName();
/* 232 */       String type = d.getDataType();
/* 233 */       String comment = d.getColumnComment();
/*     */       
/* 235 */       String maxChar = name.substring(0, 1).toUpperCase();
/* 236 */       str.append("\r\t").append("/**");
/* 237 */       str.append("\r\t").append(" *").append(comment);
/* 238 */       str.append("\r\t").append(" */");
/* 239 */       str.append("\r\t").append("private ").append(type + " ").append(name).append(";");
/* 240 */       String method = maxChar + name.substring(1, name.length());
/* 241 */       getset.append("\r\t").append("public ").append(type + " ").append("get" + method + "() {\r\t");
/* 242 */       getset.append("    return this.").append(name).append(";\r\t}");
/* 243 */       getset.append("\r\t").append("public void ").append("set" + method + "(" + type + " " + name + ") {\r\t");
/* 244 */       getset.append("    this." + name + "=").append(name).append(";\r\t}");
/*     */     }
/* 246 */     this.argv = str.toString();
/* 247 */     this.method = getset.toString();
/* 248 */     return this.argv + this.method;
/*     */   }
/*     */   
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */   public String getQueryBeanFeilds(String tableName, String className)
/*     */     throws SQLException
/*     */   {
/* 259 */     List<ColumnData> dataList = getColumnDatas(tableName);
/* 260 */     StringBuffer str = new StringBuffer();
/* 261 */     StringBuffer getset = new StringBuffer();
/* 262 */     for (ColumnData d : dataList) {
/* 263 */       String name = d.getDomainPropertyName();
/* 264 */       String type = d.getDataType();
/* 265 */       String comment = d.getColumnComment();
/*     */       
/* 267 */       String maxChar = name.substring(0, 1).toUpperCase();
/* 268 */       str.append("\r\t").append("/**");
/* 269 */       str.append("\r\t").append(" *").append(comment);
/* 270 */       str.append("\r\t").append(" */");
/* 271 */       str.append("\r\t").append("private ").append(type + " ").append(name).append(";");
/* 272 */       String method = maxChar + name.substring(1, name.length());
/* 273 */       getset.append("\r\t").append("public ").append(type + " ").append("get" + method + "() {\r\t");
/* 274 */       getset.append("    return this.").append(name).append(";\r\t}");
/* 275 */       getset.append("\r\t").append("public void ").append("set" + method + "(" + type + " " + name + ") {\r\t");
/* 276 */       getset.append("    this." + name + "=").append(name).append(";\r\t}");
/*     */     }
/* 278 */     this.argv = str.toString();
/* 279 */     this.method = getset.toString();
/* 280 */     return this.argv + this.method;
/*     */   }
/*     */   
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */   public String getJdbcType(String dataType, String precision, String scale)
/*     */   {
/* 291 */     dataType = dataType.toLowerCase();
/* 292 */     if (dataType.contains("int")) {
/* 293 */       dataType = "INTEGER";
/* 294 */     } else if (dataType.contains("date")) {
/* 295 */       dataType = "TIMESTAMP";
/* 296 */     } else if (dataType.contains("time")) {
/* 297 */       dataType = "TIMESTAMP";
/* 298 */     } else if (dataType.contains("clob")) {
/* 299 */       dataType = "VARCHAR";
/* 300 */     } else if (dataType.contains("text")) {
/* 301 */       dataType = "VARCHAR";
/*     */     } else {
/* 303 */       dataType = dataType.toUpperCase();
/*     */     }
/* 305 */     return dataType;
/*     */   }
/*     */   
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */   public String getType(String dataType, String precision, String scale)
/*     */   {
/* 316 */     dataType = dataType.toLowerCase();
/* 317 */     if (dataType.contains("char")) {
/* 318 */       dataType = "String";
/* 319 */     } else if (dataType.contains("text")) {
/* 320 */       dataType = "String";
/* 321 */     } else if (dataType.contains("bigint")) {
/* 322 */       dataType = "Long";
/* 323 */     } else if (dataType.contains("int")) {
/* 324 */       dataType = "Integer";
/* 325 */     } else if (dataType.contains("float")) {
/* 326 */       dataType = "Float";
/* 327 */     } else if (dataType.contains("double")) {
/* 328 */       dataType = "Double";
/* 329 */     } else if (dataType.contains("number")) {
/* 330 */       if ((StringUtils.isNotBlank(scale)) && (Integer.parseInt(scale) > 0)) {
/* 331 */         dataType = "BigDecimal";
/* 332 */       } else if ((StringUtils.isNotBlank(precision)) && (Integer.parseInt(precision) > 6)) {
/* 333 */         dataType = "Long";
/*     */       } else {
/* 335 */         dataType = "Integer";
/*     */       }
/* 337 */     } else if (dataType.contains("decimal")) {
/* 338 */       dataType = "BigDecimal";
/* 339 */     } else if (dataType.contains("date")) {
/* 340 */       dataType = "Date";
/* 341 */     } else if (dataType.contains("time")) {
/* 342 */       dataType = "Date";
/* 343 */     } else if (dataType.contains("clob")) {
/* 344 */       dataType = "Clob";
/*     */     } else {
/* 346 */       dataType = "Object";
/*     */     }
/* 348 */     return dataType;
/*     */   }
/*     */   
/* 351 */   public void getPackage(int type, String createPath, String content, String packageName, String className, String extendsClassName, String... importName) throws Exception { if (packageName == null) {
/* 352 */       packageName = "";
/*     */     }
/* 354 */     StringBuffer sb = new StringBuffer();
/* 355 */     sb.append("package ").append(packageName).append(";\r");
/* 356 */     sb.append("\r");
/* 357 */     for (int i = 0; i < importName.length; i++) {
/* 358 */       sb.append("import ").append(importName[i]).append(";\r");
/*     */     }
/* 360 */     sb.append("\r");
/* 361 */     sb.append("/**\r *  entity. @author wolf Date:" + new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()) + "\r */");
/* 362 */     sb.append("\r");
/* 363 */     sb.append("\rpublic class ").append(className);
/* 364 */     if (extendsClassName != null) {
/* 365 */       sb.append(" extends ").append(extendsClassName);
/*     */     }
/* 367 */     if (type == 1) {
/* 368 */       sb.append(" ").append("implements java.io.Serializable {\r");
/*     */     } else {
/* 370 */       sb.append(" {\r");
/*     */     }
/* 372 */     sb.append("\r\t");
/* 373 */     sb.append("private static final long serialVersionUID = 1L;\r\t");
/* 374 */     String temp = className.substring(0, 1).toLowerCase();
/* 375 */     temp = temp + className.substring(1, className.length());
/* 376 */     if (type == 1) {
/* 377 */       sb.append("private " + className + " " + temp + "; // entity ");
/*     */     }
/* 379 */     sb.append(content);
/* 380 */     sb.append("\r}");
/* 381 */     System.out.println(sb.toString());
/* 382 */     createFile(createPath, "", sb.toString());
/*     */   }
/*     */   
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */   public String getTablesNameToClassName(String tableName)
/*     */   {
/* 395 */     tableName = tableName.toLowerCase();
/* 396 */     String[] split = tableName.split("_");
/* 397 */     if (split.length > 1) {
/* 398 */       StringBuffer sb = new StringBuffer();
/* 399 */       for (int i = 0; i < split.length; i++) {
/* 400 */         String tempTableName = split[i].substring(0, 1).toUpperCase() + split[i].substring(1, split[i].length());
/* 401 */         sb.append(tempTableName);
/*     */       }
/*     */       
/* 404 */       return sb.toString();
/*     */     }
/* 406 */     String tempTables = split[0].substring(0, 1).toUpperCase() + split[0].substring(1, split[0].length());
/* 407 */     return tempTables;
/*     */   }
/*     */   
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */   private String argv;
/*     */   
/*     */ 
/*     */ 
/*     */ 
/*     */   public String getTablesASName(String tableName)
/*     */   {
/* 421 */     tableName = tableName.toLowerCase();
/* 422 */     String[] split = tableName.split("_");
/* 423 */     if (split.length > 1) {
/* 424 */       StringBuffer sb = new StringBuffer();
/* 425 */       for (int i = 0; i < split.length; i++) {
/* 426 */         String tempTableName = split[i].substring(0, 1).toLowerCase();
/* 427 */         sb.append(tempTableName);
/*     */       }
/*     */       
/* 430 */       return sb.toString();
/*     */     }
/* 432 */     String tempTables = split[0].substring(0, 1).toLowerCase();
/* 433 */     return tempTables;
/*     */   }
/*     */   
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */   public String getcolumnNameToDomainPropertyName(String columnName)
/*     */   {
/* 447 */     columnName = columnName.toLowerCase();
/* 448 */     String[] split = columnName.split("_");
/* 449 */     if (split.length > 1) {
/* 450 */       StringBuffer sb = new StringBuffer();
/* 451 */       for (int i = 0; i < split.length; i++) {
/* 452 */         String tempTableName = split[i].substring(0, 1).toUpperCase() + split[i].substring(1, split[i].length());
/* 453 */         sb.append(tempTableName);
/*     */       }
/*     */       
/* 456 */       columnName = sb.toString();
/* 457 */       columnName = columnName.substring(0, 1).toLowerCase() + columnName.substring(1, columnName.length());
/* 458 */       return columnName;
/*     */     }
/* 460 */     columnName = split[0].substring(0, 1).toLowerCase() + split[0].substring(1, split[0].length());
/* 461 */     return columnName;
/*     */   }
/*     */   
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */   public void createFile(String path, String fileName, String str)
/*     */     throws IOException
/*     */   {
/* 476 */     FileWriter writer = new FileWriter(new File(path + fileName));
/* 477 */     writer.write(new String(str.getBytes("utf-8")));
/* 478 */     writer.flush();
/* 479 */     writer.close();
/*     */   }
/*     */   
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/* 490 */   static String selectStr = "select ";
/* 491 */   static String from = " from ";
/*     */   
/*     */   public Map<String, Object> getAutoCreateSql(String tableName) throws Exception {
/* 494 */     Map<String, Object> sqlMap = new HashMap();
/* 495 */     List<ColumnData> columnDatas = getColumnDatas(tableName);
/* 496 */     String columns = getColumnSplit(columnDatas);
/* 497 */     String[] columnList = getColumnList(columns);
/* 498 */     String columnFields = getColumnFields(columns);
/* 499 */     String insert = "INSERT INTO " + tableName + "(" + columns.replaceAll("\\|", ",") + ")\n values(#{" + columns.replaceAll("\\|", "},#{") + "})";
/* 500 */     String update = getUpdateSql(tableName, columnList);
/* 501 */     String updateSelective = getUpdateSelectiveSql(tableName, columnDatas);
/* 502 */     String selectById = getSelectByIdSql(tableName, columnList);
/* 503 */     String delete = getDeleteSql(tableName, columnList);
/* 504 */     sqlMap.put("columnList", columnList);
/* 505 */     sqlMap.put("columnFields", columnFields);
/* 506 */     sqlMap.put("insert", insert);
/* 507 */     sqlMap.put("update", update);
/* 508 */     sqlMap.put("delete", delete);
/* 509 */     sqlMap.put("updateSelective", updateSelective);
/* 510 */     sqlMap.put("selectById", selectById);
/* 511 */     return sqlMap;
/*     */   }
/*     */   
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */   public String getDeleteSql(String tableName, String[] columnsList)
/*     */     throws SQLException
/*     */   {
/* 522 */     StringBuffer sb = new StringBuffer();
/* 523 */     sb.append("delete ");
/* 524 */     sb.append("\t from ").append(tableName).append(" where ");
/* 525 */     sb.append(columnsList[0]).append(" = #{").append(columnsList[0]).append("}");
/* 526 */     return sb.toString();
/*     */   }
/*     */   
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */   public String getSelectByIdSql(String tableName, String[] columnsList)
/*     */     throws SQLException
/*     */   {
/* 537 */     StringBuffer sb = new StringBuffer();
/* 538 */     sb.append("select <include refid=\"Base_Column_List\" /> \n");
/* 539 */     sb.append("\t from ").append(tableName).append(" where ");
/* 540 */     sb.append(columnsList[0]).append(" = #{").append(columnsList[0]).append("}");
/* 541 */     return sb.toString();
/*     */   }
/*     */   
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */   public String getColumnFields(String columns)
/*     */     throws SQLException
/*     */   {
/* 551 */     String fields = columns;
/* 552 */     if ((fields != null) && (!"".equals(fields))) {
/* 553 */       fields = fields.replaceAll("[|]", ",");
/*     */     }
/* 555 */     return fields;
/*     */   }
/*     */   
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */   public String[] getColumnList(String columns)
/*     */     throws SQLException
/*     */   {
/* 565 */     String[] columnList = columns.split("[|]");
/* 566 */     return columnList;
/*     */   }
/*     */   
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */   public String getUpdateSql(String tableName, String[] columnsList)
/*     */     throws SQLException
/*     */   {
/* 577 */     StringBuffer sb = new StringBuffer();
/*     */     
/* 579 */     for (int i = 1; i < columnsList.length; i++) {
/* 580 */       String column = columnsList[i];
/* 581 */       if (!"CREATETIME".equals(column.toUpperCase()))
/*     */       {
/*     */ 
/* 584 */         if ("UPDATETIME".equals(column.toUpperCase())) {
/* 585 */           sb.append(column + "=now()");
/*     */         } else {
/* 587 */           sb.append(column + "=#{" + column + "}");
/*     */         }
/* 589 */         if (i + 1 < columnsList.length)
/* 590 */           sb.append(",");
/*     */       }
/*     */     }
/* 593 */     String update = "update " + tableName + " set " + sb.toString() + " where " + columnsList[0] + "=#{" + columnsList[0] + "}";
/* 594 */     return update;
/*     */   }
/*     */   
/*     */   public String getUpdateSelectiveSql(String tableName, List<ColumnData> columnList) throws SQLException {
/* 598 */     StringBuffer sb = new StringBuffer();
/* 599 */     ColumnData cd = (ColumnData)columnList.get(0);
/* 600 */     sb.append("\t<trim  suffixOverrides=\",\" >\n");
/* 601 */     for (int i = 1; i < columnList.size(); i++) {
/* 602 */       ColumnData data = (ColumnData)columnList.get(i);
/* 603 */       String columnName = data.getColumnName();
/* 604 */       sb.append("\t<if test=\"").append(columnName).append(" != null ");
/*     */       
/* 606 */       if ("String" == data.getDataType()) {
/* 607 */         sb.append(" and ").append(columnName).append(" != ''");
/*     */       }
/* 609 */       sb.append(" \">\n\t\t");
/* 610 */       sb.append(columnName + "=#{" + columnName + "},\n");
/* 611 */       sb.append("\t</if>\n");
/*     */     }
/* 613 */     sb.append("\t</trim>");
/* 614 */     String update = "update " + tableName + " set \n" + sb.toString() + " where " + cd.getColumnName() + "=#{" + cd.getColumnName() + "}";
/* 615 */     return update;
/*     */   }
/*     */   
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */   public String getColumnSplit(List<ColumnData> columnList)
/*     */     throws SQLException
/*     */   {
/* 631 */     StringBuffer commonColumns = new StringBuffer();
/* 632 */     for (ColumnData data : columnList) {
/* 633 */       commonColumns.append(data.getColumnName() + "|");
/*     */     }
/* 635 */     return commonColumns.delete(commonColumns.length() - 1, commonColumns.length()).toString();
/*     */   }
/*     */ }


/* Location:              /Users/guo/.m2/repository/org/jeewxframework/P3-Codegenerate/2.0.1/P3-Codegenerate-2.0.1.jar!/org/jeecgframework/p3/cg/CreateBean.class
 * Java compiler version: 6 (50.0)
 * JD-Core Version:       0.7.1
 */